<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="数据库备份" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doNew(){
		ShowConfirm('确认框','确定开始备份吗？',340,80,"doNewCallBack()");
	}
	function doNewCallBack(){
		if(popRetVal!=null){
			var url="/system/DbBackupNew.ihtm?show_msg=1";
			ShowIframe("请稍候 ...",url,400,200,"refreshWin()");
		}
	}
	function refreshWin(){
		//if(popRetVal!=null){
			window.location=window.location;
		//}
	}
	function doDelete(id){
		<c:if test="${currentUser.user.userType!=1}">
			ShowAlert('提示框','只有admin账号才能删除数据库备份文件',200,100);
		</c:if>
		<c:if test="${currentUser.user.userType==1}">
			ShowConfirm('确认框','确定删除吗？',340,80,"doDeleteCallBack('"+id+"')");
		</c:if>
	}
	function doDeleteCallBack(id){
		if(popRetVal!=null){
			var fromUrl=getFromUrl();
			window.location="/system/DbBackupDelete.ihtm?id_str="+id+"&from_url="+fromUrl;
		}
	}
	
	function getFromUrl(){
		var fromUrl="/system/DbBackupList.ihtm?current_page=${qr.pageIndex}";
		return encodeURIComponent(fromUrl);
	}
	function doGo(pageIndex){
		window.location="/system/DbBackupList.ihtm?current_page="+pageIndex;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function doCancel(){
		window.close();
	}
	function DoubleClick(it){
	}
	function getMultiIds(){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		for (i=0;i<ob_arr.length;i++){
			if ((ob_arr[i].checked == true)){
				if(str!=""){
					str=str+";";
				}
				str = str+ob_arr[i].value;
			}
		}
		return str;
	}
	function doMultiDelete(){
		var ids=getMultiIds();
		if(ids==""){
			ShowAlert('提示框','请选择要删除的记录',200,100);
		}else{
			doDelete(ids);
		}
	}
</script>
</head>
<body oncontextmenu="return false" class="sheet" style="text-align:center;">
<div class="sheet-main" style="width:860px;text-align:left;margin:auto;">
  <div class="sheet-top">
    <div class="content">
      <h2>数据库备份</h2>
      <p>记录数据库的备份时间及操作人；系统每次备份都是全部数据，只需要保留最后一个备份文件</p>
    </div>
  </div>
  <div class="sheet-list">
    <div class="search-business">
	    <div class="add_content">
		<table width="746">
			<tbody>
				<tr>
					<td>
						<c:if test="${ent.dbAb=='Y'}">自动备份时间：${ent.dbAbHour}:<c:if test="${ent.dbAbMinute<10}">0</c:if>${ent.dbAbMinute}</c:if>
						<c:if test="${ent.dbAb=='N'}">没有设置自动备份数据库</c:if>
						<c:if test="${ent.dbAdel=='Y'}"> 【自动删除2周前的备份】</c:if>
						<a href="http://www.ekingcn.com/school/cjwtjjff_1753_253.html" target="_blank">如何设置双重备份到云盘<img src="/images/play_button.gif"></a>
					</td>
					<td width="260" align="right">
						<input type="button" class="buttom search-add" value="  备 份 " onClick="doNew();">
						<input type="button" class="buttom search-remo" value=" 删除" onClick="doMultiDelete();" title="只有admin账号才能删除数据库备份文件" <c:if test="${currentUser.user.userType!=1}">disabled="true"</c:if>>
					</td>
				</tr>
			</tbody>
		</table>
		</div>
	     <%@include file="../inc/AlertMsg.jsp"%>	     
	     <div class="table-list">
	        <table width="100%">
	          <tr>
	          		<th width="14"><input type="checkbox" onClick="javascript:checkall(this);"></th>
					<th width="30%">日期</th>
					<th width="20%">备份人</th>
					<th width="20%">状态</th>
					<th width="20%">文件大小</th>
					<th width="10%">操作</th>
				</tr>
				<c:forEach var="item" items="${qr.list}" varStatus="i">
				<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
				<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
				<c:set var="defaultFontColor" value="#000000" />
				<c:if test="${item.completeFlag=='N'}"><c:set var="defaultFontColor" value="#0000cc" /></c:if>
				<c:if test="${item.completeFlag=='F'}"><c:set var="defaultFontColor" value="#ff0000" /></c:if>
				<tr class="${trClass}" style="color:${defaultFontColor};cursor:pointer;" defaultFontColor="${defaultFontColor}" index="${i.index+1}" ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this,true)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
					<td ><input type="checkbox" onClick="javascript:ClickCheck(this,true);" name='query_checkbox' value="${item.id}"></td>
					<td><fmt:formatDate value="${item.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					<td>${item.createrName}</td>
					<td>
						<c:if test="${item.completeFlag=='Y'}">备份完成</c:if>
						<c:if test="${item.completeFlag=='N'}">未完成</c:if>
						<c:if test="${item.completeFlag=='F'}">备份失败</c:if>
					</td>
					<td><commonTag:parseFileSize fileSize="${item.fileSize}" /></td>
					<td>
						<a href="javascript:doDelete('${item.id}');">删除</a>
					</td>
				</tr>
				</c:forEach>
			</table>	
			<%@include file="../inc/Pages.jsp"%>
	     </div>  
	   </div>  
  </div>
</div>
</body>
</html>